<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"> 

<h:head>
	<h:outputStylesheet library="css" name="userHomePage.css"/>
	<title>TravelDream</title>
	<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'/>
</h:head> 
<body> 

	<h:outputStylesheet library="css" name="primefaces-style.css"/>
	
	<div id="header">
		<div id="logo">
			<h:link outcome="homePage" >
				<h:outputText id="logo" value="TravelDream" />
			</h:link>
		</div>
		
		<div id="userInfo">
			<h:link outcome="userInfo" >
			<h:outputText id="userName" value="#{searchBar.currentUser.firstName}" />
			</h:link>	
			
		</div>
		
		<div id="logout">
			<h:form>
				<p:commandButton id="logoutButton" value="logout" action="#{logout.logout()}"/>
			</h:form>
		</div>
	</div>
	
	<div id="lineHome">
	
	</div>
	<div id="confirmPanel">
			<p:panel header="Prenotation Confirmed" rendered="#{searchBar.prenotationConfirmed}">
				    <h:outputText value="#{searchBar.prenotationOK}" />
			</p:panel>
		</div>
	
	<div id="content">
		
	<h:form>
	<h:panelGrid columns="3" cellpadding="0">
		<p:inputText id="searchBar" value="#{searchBar.searchPackageDTO.keyWord}"/>
		<p:commandButton action="#{searchBar.search()}" ajax="false" value="search"/>
		<p:commandButton action="#{searchBar.showAllPackage()}" ajax="false" value="view all Packages"/>
		
		<h:outputText value="#{searchBar.errorSearchEmpty}" />
		<h:outputText value="" />
		<h:outputText value="" />
		
		<h:outputText value="#{searchBar.noResult}" />
		<h:outputText value="" />
		<h:outputText value="" />
		
	</h:panelGrid>
	
		<p:dataTable id="resultPackages" var="TravelDreamDTO"
				value="#{searchBar.resultPackageQuery}"
				rendered="#{searchBar.showResult and !searchBar.selected}"
				>
				<f:facet name="header">  
          				  	Result Packages  
       					 </f:facet>

				<p:column headerText="Name">
					<h:outputText value="#{TravelDreamDTO.packageName}" />
				</p:column>

				<p:column headerText="Description">
					<h:outputText value="#{TravelDreamDTO.description}" />
				</p:column>
				<p:column headerText="City">
					<h:outputText value="#{TravelDreamDTO.city}" />
				</p:column>

				<p:column headerText="Persons">
					<h:outputText value="#{TravelDreamDTO.numberOfPerson}" />
				</p:column>
				
				<p:column headerText="From">
					<h:outputText value="#{TravelDreamDTO.arrivo}" />
				</p:column>
				
				<p:column headerText="Nights">
					<h:outputText value="#{TravelDreamDTO.numberOfNights}" />
				</p:column>
			
				<p:column headerText="">
					<p:commandButton value="select" action="#{searchBar.selectPackage(TravelDreamDTO)}" ajax="false"/>
				</p:column>

			</p:dataTable>	
		</h:form>

		<h:form>
		
		<p:dataTable id="allPackages" var="TravelDreamDTO"
				value="#{searchBar.allPackageDTOs}"
				rendered="#{searchBar.allResult and !searchBar.selected}"
				>
				<f:facet name="header">  
          				  	All Packages  
       					 </f:facet>

				<p:column headerText="Name">
					<h:outputText value="#{TravelDreamDTO.packageName}" />
				</p:column>

				<p:column headerText="Description">
					<h:outputText value="#{TravelDreamDTO.description}" />
				</p:column>
				<p:column headerText="City">
					<h:outputText value="#{TravelDreamDTO.city}" />
				</p:column>

				<p:column headerText="Person">
					<h:outputText value="#{TravelDreamDTO.numberOfPerson}" />
				</p:column>
				
				<p:column headerText="From">
					<h:outputText value="#{TravelDreamDTO.arrivo}" />
				</p:column>
				
				<p:column headerText="Nights">
					<h:outputText value="#{TravelDreamDTO.numberOfNights}" />
				</p:column>
			
				<p:column headerText="">
					<p:commandButton value="select" action="#{searchBar.selectPackage(TravelDreamDTO)}" ajax="false"/>
				</p:column>

			</p:dataTable>	
		</h:form>
		
		<p:panel header="Choose outgoing Flight" rendered="#{searchBar.selected and searchBar.outgoing}" styleClass="blue-header">
		
		<h:form id="flightRelatedToPackageOutgoing"  >  
		    	<p:dataTable id="dataTableResultFlight" var="FlightDTO" value="#{searchBar.flightRelated}">  
		    	 <f:facet name="header">  
		    	 	Possible outgoing flights
		    	  </f:facet> 

					<p:column headerText="DepartureCity">  
			            <h:outputText value="#{FlightDTO.departureCity}" />  
			        </p:column>  
			     
			      <p:column headerText="ArrivalCity">  
			            <h:outputText value="#{FlightDTO.arrivalCity}" />  
			        </p:column>  
			  
			        
			 		 <p:column headerText="Data">  
			            <h:outputText value="#{FlightDTO.data}" />  
			        </p:column>
			        
			         <p:column headerText="Price(EUR)">  
			         	<h:outputText value="#{FlightDTO.price}" />  
			        </p:column>
			        
			        <p:column headerText="">  
			        <p:commandButton value="Choose" action="#{searchBar.addOutGoingFlight(FlightDTO)}" 
			        ajax="false">
			        </p:commandButton>
			        
			        </p:column>
			     		  
    	</p:dataTable>  
    	   
	</h:form>
		</p:panel>
		
			<p:panel header="Choose return Flight" rendered="#{searchBar.selected and searchBar.return}" styleClass="blue-header">
		
		<h:form id="flightRelatedToPackageReturn" >  
		    	<p:dataTable id="dataTableResultFlight" var="FlightDTO" value="#{searchBar.flightRelated}">  
		    	 <f:facet name="header">  
		    	 	Possible return flights
		    	  </f:facet> 

			      <p:column headerText="ArrivalCity">  
			            <h:outputText value="#{FlightDTO.arrivalCity}" />  
			        </p:column>  
			  
			      <p:column headerText="DepartureCity">  
			            <h:outputText value="#{FlightDTO.departureCity}" />  
			        </p:column>  
			        
			 		 <p:column headerText="Data">  
			            <h:outputText value="#{FlightDTO.data}" />  
			        </p:column>
			        
			         <p:column headerText="Price">  
			            <h:outputText value="#{FlightDTO.price}" />  
			        </p:column>
			        
			        <p:column headerText="">  
			        <p:commandButton value="Choose" action="#{searchBar.returnFlight(FlightDTO)}"
			        ajax="false">
			        </p:commandButton>
			        
			        </p:column>
			     		  
    	</p:dataTable>  
    	   
	</h:form>
</p:panel>

<p:panel header="Choose Hotel" rendered="#{searchBar.selected and searchBar.hotel}" styleClass="orange-header">

			<h:form>  
		    	<p:dataTable id="hotelDataTable" var="HotelDTO" value="#{searchBar.hotelRelated}">  
		    	 <f:facet name="header">  
          				  	All Hotel  
       					 </f:facet> 
       					 
			      <p:column headerText="Description">  
			            <h:outputText value="#{HotelDTO.description}" />  
			        </p:column>  
			  
			      <p:column headerText="name">  
			            <h:outputText value="#{HotelDTO.name}" />  
			        </p:column>  
			        
			         <p:column headerText="city">  
			            <h:outputText value="#{HotelDTO.city}" />  
			        </p:column>  
			        
			 		 <p:column headerText="Address">  
			            <h:outputText value="#{HotelDTO.address}" />  
			        </p:column>
			        
			         <p:column headerText="stars">  
			            <p:rating value="#{HotelDTO.stars}" readonly="true" />  
			        </p:column>
			        
			        <p:column headerText="Price(EUR x night">  
			            <h:outputText value="#{HotelDTO.price}" />  
			        </p:column>

			        
			         <p:column headerText="">  
			        <p:commandButton value="Choose" action="#{searchBar.addHotel(HotelDTO)}" ajax="false"/>
			        </p:column>
			     		  
    	</p:dataTable>  
	</h:form>  
	</p:panel>	
	
	<p:panel header="Choose Excursion" rendered="#{searchBar.selected and searchBar.excursion}" styleClass="green-header">

	
		<h:form>  
		    	<p:dataTable id="excursion" var="ExcursionDTO" value="#{searchBar.excursionRelated}">  
		    	 <f:facet name="header">  
          				  	 Excursion 
       					 </f:facet> 

			      <p:column headerText="name">  
			            <h:outputText value="#{ExcursionDTO.name}" />  
			        </p:column>  
			        
			        <p:column headerText="Description">  
			            <h:outputText value="#{ExcursionDTO.description}" />  
			        </p:column> 
			        
			         <p:column headerText="price">  
			            <h:outputText value="#{ExcursionDTO.price}" />  
			        </p:column>  

			        
			         <p:column headerText="">  
			        <p:commandButton value="Choose" action="#{searchBar.addExcursion(ExcursionDTO)}" ajax="false"/>
			        </p:column>
			     		  
    	</p:dataTable>  
	</h:form> 
		
	</p:panel>
	 
		<p:panel header="Recap" rendered="#{searchBar.selected and searchBar.recap and !searchBar.prenotationConfirmed}">
			<p:panel header="General">
				<p:panelGrid columns="2" cellpadding="0">
					<h:outputText value="Name: " />
					<h:outputText value="#{searchBar.packageSelecteDto.packageName}" />
					
					<h:outputText value="City: " />
					<h:outputText value="#{searchBar.packageSelecteDto.city}" />
					
					<h:outputText value="Description: " />
					<h:outputText value="#{searchBar.packageSelecteDto.description}" />
					
					<h:outputText value="Persons: " />
					<h:outputText value="#{searchBar.packageSelecteDto.numberOfPerson}" />
					
					<h:outputText value="From " />
					<h:outputText value="#{searchBar.packageSelecteDto.arrivo}" />
					
					<h:outputText value="Nights: " />
					<h:outputText value="#{searchBar.packageSelecteDto.numberOfNights}" />
				</p:panelGrid>
				</p:panel>
				<p:panel header="Outgoing Flight" styleClass="blue-header">
					<p:panelGrid columns="2" cellpadding="0">
					
						<h:outputText value="From: " />
						<h:outputText value="#{searchBar.outGoingFlight.departureCity}" />
						
						<h:outputText value="To: " />
						<h:outputText value="#{searchBar.outGoingFlight.arrivalCity}" />
						
						<h:outputText value="Price: " />
						<h:outputText value="#{searchBar.outGoingFlight.price}" />
					</p:panelGrid>
				</p:panel>
				
				<p:panel header="Return Flight" styleClass="blue-header">
					<p:panelGrid columns="2" cellpadding="0">
					
						<h:outputText value="From: " />
						<h:outputText value="#{searchBar.returnFlight.departureCity}" />
						
						<h:outputText value="To: " />
						<h:outputText value="#{searchBar.returnFlight.arrivalCity}" />
						
						<h:outputText value="Price(EUR): " />
						<h:outputText value="#{searchBar.returnFlight.price}" />
					</p:panelGrid>
				</p:panel>
				
				<p:panel header="Hotel: " styleClass="orange-header">
					<p:panelGrid columns="2" cellpadding="0">
					
						<h:outputText value="Name: " />
						<h:outputText value="#{searchBar.hotelChosed.name}" />
						
						<h:outputText value="City: " />
						<h:outputText value="#{searchBar.hotelChosed.city}" />
						
						<h:outputText value="Description: " />
						<h:outputText value="#{searchBar.hotelChosed.description}" />
						
						<h:outputText value="Address: " />
						<h:outputText value="#{searchBar.hotelChosed.address}" />
						
						<h:outputText value="Stars: " />
						<h:outputText value="#{searchBar.hotelChosed.stars}" />
						
						<h:outputText value="Price: " />
						<h:outputText value="#{searchBar.hotelChosed.price}" />
					</p:panelGrid>
				</p:panel>
				
				<p:panel header="Excursion" styleClass="green-header">
					<p:panelGrid columns="2" cellpadding="0">
					
						<h:outputText value="Name: " />
						<h:outputText value="#{searchBar.excursionChosed.name}" />
						
						<h:outputText value="Description: " />
						<h:outputText value="#{searchBar.excursionChosed.description}" />
						
						<h:outputText value="Price: " />
						<h:outputText value="#{searchBar.excursionChosed.price}" />

					</p:panelGrid>
				</p:panel>
				
				<p:panel header="Total Price">
					<p:panelGrid columns="2" cellpadding="0">
					
						<h:outputText value="Total Price (EUR): " />
						<h:outputText value="#{searchBar.prenotationDTO.price}" />

					</p:panelGrid>
				</p:panel>
				
				<h:form>
					<p:commandButton value="Confirm" action="#{searchBar.confirm()}" ajax="false"/>
				    <p:commandButton value="Cancel" action="#{searchBar.cancel()}" ajax="false"/>

				</h:form>
				
				
			
		</p:panel>
	
		</div>
		
		
	
</body> 
</html>